<?php

/**
 * Comment form base class.
 *
 * @method Comment getObject() Returns the current form's model object
 *
 * @package    iEasy
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseCommentForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'comment_id'     => new sfWidgetFormInputHidden(),
      'content_id'     => new sfWidgetFormInputText(),
      'content_type_i' => new sfWidgetFormInputText(),
      'user_id'        => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Users'), 'add_empty' => true)),
      'create_time'    => new sfWidgetFormDateTime(),
      'modify_time'    => new sfWidgetFormDateTime(),
      'body'           => new sfWidgetFormTextarea(),
      'status_id'      => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Status'), 'add_empty' => true)),
      'user_ip'        => new sfWidgetFormInputText(),
    ));

    $this->setValidators(array(
      'comment_id'     => new sfValidatorChoice(array('choices' => array($this->getObject()->get('comment_id')), 'empty_value' => $this->getObject()->get('comment_id'), 'required' => false)),
      'content_id'     => new sfValidatorInteger(array('required' => false)),
      'content_type_i' => new sfValidatorInteger(array('required' => false)),
      'user_id'        => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Users'), 'required' => false)),
      'create_time'    => new sfValidatorDateTime(array('required' => false)),
      'modify_time'    => new sfValidatorDateTime(array('required' => false)),
      'body'           => new sfValidatorString(array('required' => false)),
      'status_id'      => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Status'), 'required' => false)),
      'user_ip'        => new sfValidatorString(array('max_length' => 50, 'required' => false)),
    ));

    $this->widgetSchema->setNameFormat('comment[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Comment';
  }

}
